﻿<template>
  <div>
    <a-card :bordered="false" :bodyStyle="tstyle">

      <div class="table-page-search-wrapper" v-if="hasPerm('SysEmpInfo:page')">
        <a-form layout="inline">
          <a-row :gutter="48">
            <a-col :md="8" :sm="24">
              <a-form-item label="EMP_CODE ">
                <a-input v-model="queryParam.empCode" allow-clear placeholder="请输入EMP_CODE "/>
              </a-form-item>
            </a-col>
            <a-col :md="8" :sm="24">
              <a-form-item label="EMP_NAME ">
                <a-input v-model="queryParam.empName" allow-clear placeholder="请输入EMP_NAME "/>
              </a-form-item>
            </a-col><template v-if="advanced">
              <a-col :md="8" :sm="24">
                <a-form-item label="INPUT_CODE ">
                  <a-input v-model="queryParam.inputCode" allow-clear placeholder="请输入INPUT_CODE "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="EMP_SEX ">
                  <a-input v-model="queryParam.empSex" allow-clear placeholder="请输入EMP_SEX "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="EMP_BIRTHDAY ">
                  <a-input v-model="queryParam.empBirthday" allow-clear placeholder="请输入EMP_BIRTHDAY "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="BIRTH_PLACE ">
                  <a-input v-model="queryParam.birthPlace" allow-clear placeholder="请输入BIRTH_PLACE "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="CITIZENSHIP ">
                  <a-input v-model="queryParam.citizenship" allow-clear placeholder="请输入CITIZENSHIP "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="NATION ">
                  <a-input v-model="queryParam.nation" allow-clear placeholder="请输入NATION "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="ID_NO ">
                  <a-input v-model="queryParam.idNo" allow-clear placeholder="请输入ID_NO "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="MAILING_ADDRESS ">
                  <a-input v-model="queryParam.mailingAddress" allow-clear placeholder="请输入MAILING_ADDRESS "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="ZIP_CODE ">
                  <a-input v-model="queryParam.zipCode" allow-clear placeholder="请输入ZIP_CODE "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="PHONE_NUMBER_HOME ">
                  <a-input v-model="queryParam.phoneNumberHome" allow-clear placeholder="请输入PHONE_NUMBER_HOME "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="PHONE_NUMBER_BUSINESS ">
                  <a-input v-model="queryParam.phoneNumberBusiness" allow-clear placeholder="请输入PHONE_NUMBER_BUSINESS "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="EMP_JOB ">
                  <a-input v-model="queryParam.empJob" allow-clear placeholder="请输入EMP_JOB "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="EMP_TITLE ">
                  <a-input v-model="queryParam.empTitle" allow-clear placeholder="请输入EMP_TITLE "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="DOCT_ATTR ">
                  <a-input v-model="queryParam.doctAttr" allow-clear placeholder="请输入DOCT_ATTR "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="DOCT_COUNTERMARK_NO ">
                  <a-input v-model="queryParam.doctCountermarkNo" allow-clear placeholder="请输入DOCT_COUNTERMARK_NO "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="SYS_USER_CODE ">
                  <a-input v-model="queryParam.sysUserCode" allow-clear placeholder="请输入SYS_USER_CODE "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="VIP_INDICATOR ">
                  <a-input v-model="queryParam.vipIndicator" allow-clear placeholder="请输入VIP_INDICATOR "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="CREATE_OPERATOR ">
                  <a-input v-model="queryParam.createOperator" allow-clear placeholder="请输入CREATE_OPERATOR "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="MODEFY_OPERATOR ">
                  <a-input v-model="queryParam.modefyOperator" allow-clear placeholder="请输入MODEFY_OPERATOR "/>
                </a-form-item>
              </a-col><a-col :md="8" :sm="24">
                <a-form-item label="MODEFY_DATE ">
                  <a-date-picker style="width: 100%" placeholder="请选择MODEFY_DATE " v-model="queryParam.modefyDateDate" @change="onChangemodefyDate"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="INPUT_CODE_WB ">
                  <a-input v-model="queryParam.inputCodeWb" allow-clear placeholder="请输入INPUT_CODE_WB "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="DEPT_CODE ">
                  <a-input v-model="queryParam.deptCode" allow-clear placeholder="请输入DEPT_CODE "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="DEPT_NAME ">
                  <a-input v-model="queryParam.deptName" allow-clear placeholder="请输入DEPT_NAME "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="NURSE_STATION_CODE ">
                  <a-input v-model="queryParam.nurseStationCode" allow-clear placeholder="请输入NURSE_STATION_CODE "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="NURSE_STATION_NAME ">
                  <a-input v-model="queryParam.nurseStationName" allow-clear placeholder="请输入NURSE_STATION_NAME "/>
                </a-form-item>
              </a-col><a-col :md="8" :sm="24">
                <a-form-item label="创建时间">
                  <a-date-picker style="width: 100%" placeholder="请选择创建时间" v-model="queryParam.createDateDate" @change="onChangecreateDate"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="创建者Id">
                  <a-input v-model="queryParam.createUserId" allow-clear placeholder="请输入创建者Id"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="创建者名称">
                  <a-input v-model="queryParam.createUserName" allow-clear placeholder="请输入创建者名称"/>
                </a-form-item>
              </a-col><a-col :md="8" :sm="24">
                <a-form-item label="更新时间">
                  <a-date-picker style="width: 100%" placeholder="请选择更新时间" v-model="queryParam.modifyDateDate" @change="onChangemodifyDate"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="修改者Id">
                  <a-input v-model="queryParam.modifyUserId" allow-clear placeholder="请输入修改者Id"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="修改者名称">
                  <a-input v-model="queryParam.modifyUserName" allow-clear placeholder="请输入修改者名称"/>
                </a-form-item>
              </a-col><a-col :md="8" :sm="24">
                <a-form-item label="删除时间">
                  <a-date-picker style="width: 100%" placeholder="请选择删除时间" v-model="queryParam.deleteDateDate" @change="onChangedeleteDate"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="删除者ID">
                  <a-input v-model="queryParam.deleteUserId" allow-clear placeholder="请输入删除者ID"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="删除者姓名">
                  <a-input v-model="queryParam.deleteUserName" allow-clear placeholder="请输入删除者姓名"/>
                </a-form-item>
              </a-col>            </template>

            <a-col :md="8" :sm="24" >
              <span class="table-page-search-submitButtons">
                <a-button type="primary" @click="$refs.table.refresh(true)" >查询</a-button>
                <a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
                <a @click="toggleAdvanced" style="margin-left: 8px"> {{ advanced ? '收起' : '展开' }}
                  <a-icon :type="advanced ? 'up' : 'down'"/>
                </a>
              </span>
            </a-col>

          </a-row>
        </a-form>
      </div>
    </a-card>
    <a-card :bordered="false">
      <s-table
        ref="table"
        :columns="columns"
        :data="loadData"
        :alert="true"
        :rowKey="(record) => record.iD"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }">
        <template class="table-operator" slot="operator" v-if="hasPerm('SysEmpInfo:add')" >
          <a-button type="primary" v-if="hasPerm('SysEmpInfo:add')" icon="plus" @click="$refs.addForm.add()">新增人员信息</a-button>
        </template>
        <span slot="action" slot-scope="text, record">
          <a v-if="hasPerm('SysEmpInfo:edit')" @click="$refs.editForm.edit(record)">编辑</a>
          <a-divider type="vertical" v-if="hasPerm('SysEmpInfo:edit') & hasPerm('SysEmpInfo:delete')"/>
          <a-popconfirm v-if="hasPerm('SysEmpInfo:delete')" placement="topRight" title="确认删除？" @confirm="() => SysEmpInfoDelete(record)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </s-table>
      <add-form ref="addForm" @ok="handleOk" />
      <edit-form ref="editForm" @ok="handleOk" />
    </a-card>
  </div>
</template>
<script>
  import { STable } from '@/components'
  import moment from 'moment'
  import { SysEmpInfoPage, SysEmpInfoDelete } from '@/api/modular/main/SysEmpInfoManage'
  import addForm from './addForm.vue'
  import editForm from './editForm.vue'
  export default {
    components: {
      STable,
      addForm,
      editForm
    },
    data () {
      return {
        advanced: false, // 高级搜索 展开/关闭
        queryParam: {},
        columns: [
          {
            title: 'EMP_CODE ',
            align: 'center',
            dataIndex: 'empCode'
          },
          {
            title: 'EMP_NAME ',
            align: 'center',
            dataIndex: 'empName'
          },
          {
            title: 'INPUT_CODE ',
            align: 'center',
            dataIndex: 'inputCode'
          },
          {
            title: 'EMP_SEX ',
            align: 'center',
            dataIndex: 'empSex'
          },
          {
            title: 'EMP_BIRTHDAY ',
            align: 'center',
            dataIndex: 'empBirthday'
          },
          {
            title: 'BIRTH_PLACE ',
            align: 'center',
            dataIndex: 'birthPlace'
          },
          {
            title: 'CITIZENSHIP ',
            align: 'center',
            dataIndex: 'citizenship'
          },
          {
            title: 'NATION ',
            align: 'center',
            dataIndex: 'nation'
          },
          {
            title: 'ID_NO ',
            align: 'center',
            dataIndex: 'idNo'
          },
          {
            title: 'MAILING_ADDRESS ',
            align: 'center',
            dataIndex: 'mailingAddress'
          },
          {
            title: 'ZIP_CODE ',
            align: 'center',
            dataIndex: 'zipCode'
          },
          {
            title: 'PHONE_NUMBER_HOME ',
            align: 'center',
            dataIndex: 'phoneNumberHome'
          },
          {
            title: 'PHONE_NUMBER_BUSINESS ',
            align: 'center',
            dataIndex: 'phoneNumberBusiness'
          },
          {
            title: 'EMP_JOB ',
            align: 'center',
            dataIndex: 'empJob'
          },
          {
            title: 'EMP_TITLE ',
            align: 'center',
            dataIndex: 'empTitle'
          },
          {
            title: 'DOCT_ATTR ',
            align: 'center',
            dataIndex: 'doctAttr'
          },
          {
            title: 'DOCT_COUNTERMARK_NO ',
            align: 'center',
            dataIndex: 'doctCountermarkNo'
          },
          {
            title: 'SYS_USER_CODE ',
            align: 'center',
            dataIndex: 'sysUserCode'
          },
          {
            title: 'VIP_INDICATOR ',
            align: 'center',
            dataIndex: 'vipIndicator'
          },
          {
            title: 'CREATE_OPERATOR ',
            align: 'center',
            dataIndex: 'createOperator'
          },
          {
            title: 'MODEFY_OPERATOR ',
            align: 'center',
            dataIndex: 'modefyOperator'
          },
          {
            title: 'MODEFY_DATE ',
            align: 'center',
            dataIndex: 'modefyDate'
          },
          {
            title: 'INPUT_CODE_WB ',
            align: 'center',
            dataIndex: 'inputCodeWb'
          },
          {
            title: 'DEPT_CODE ',
            align: 'center',
            dataIndex: 'deptCode'
          },
          {
            title: 'DEPT_NAME ',
            align: 'center',
            dataIndex: 'deptName'
          },
          {
            title: 'NURSE_STATION_CODE ',
            align: 'center',
            dataIndex: 'nurseStationCode'
          },
          {
            title: 'NURSE_STATION_NAME ',
            align: 'center',
            dataIndex: 'nurseStationName'
          },
          {
            title: '创建时间',
            align: 'center',
            dataIndex: 'createDate'
          },
          {
            title: '创建者Id',
            align: 'center',
            dataIndex: 'createUserId'
          },
          {
            title: '创建者名称',
            align: 'center',
            dataIndex: 'createUserName'
          },
          {
            title: '更新时间',
            align: 'center',
            dataIndex: 'modifyDate'
          },
          {
            title: '修改者Id',
            align: 'center',
            dataIndex: 'modifyUserId'
          },
          {
            title: '修改者名称',
            align: 'center',
            dataIndex: 'modifyUserName'
          },
          {
            title: '删除时间',
            align: 'center',
            dataIndex: 'deleteDate'
          },
          {
            title: '删除者ID',
            align: 'center',
            dataIndex: 'deleteUserId'
          },
          {
            title: '删除者姓名',
            align: 'center',
            dataIndex: 'deleteUserName'
          }
        ],
        tstyle: { 'padding-bottom': '0px', 'margin-bottom': '10px' },
        // 加载数据方法 必须为 Promise 对象
        loadData: parameter => {
          return SysEmpInfoPage(Object.assign(parameter, this.switchingDate())).then((res) => {
            return res.data
          })
        },
        selectedRowKeys: [],
        selectedRows: []
      }
    },
    created () {
      if (this.hasPerm('SysEmpInfo:edit') || this.hasPerm('SysEmpInfo:delete')) {
        this.columns.push({
          title: '操作',
          width: '150px',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' }
        })
      }
    },
    methods: {
      moment,
      /**
       * 查询参数组装
       */
      switchingDate () {
        const queryParammodefyDate = this.queryParam.modefyDateDate
        if (queryParammodefyDate != null) {
            this.queryParam.modefyDate = moment(queryParammodefyDate).format('YYYY-MM-DD')
            if (queryParammodefyDate.length < 1) {
                delete this.queryParam.modefyDate
            }
        }
        const queryParamcreateDate = this.queryParam.createDateDate
        if (queryParamcreateDate != null) {
            this.queryParam.createDate = moment(queryParamcreateDate).format('YYYY-MM-DD')
            if (queryParamcreateDate.length < 1) {
                delete this.queryParam.createDate
            }
        }
        const queryParammodifyDate = this.queryParam.modifyDateDate
        if (queryParammodifyDate != null) {
            this.queryParam.modifyDate = moment(queryParammodifyDate).format('YYYY-MM-DD')
            if (queryParammodifyDate.length < 1) {
                delete this.queryParam.modifyDate
            }
        }
        const queryParamdeleteDate = this.queryParam.deleteDateDate
        if (queryParamdeleteDate != null) {
            this.queryParam.deleteDate = moment(queryParamdeleteDate).format('YYYY-MM-DD')
            if (queryParamdeleteDate.length < 1) {
                delete this.queryParam.deleteDate
            }
        }
        const obj = JSON.parse(JSON.stringify(this.queryParam))
        return obj
      },
      SysEmpInfoDelete (record) {
        SysEmpInfoDelete(record).then((res) => {
          if (res.success) {
            this.$message.success('删除成功')
            this.$refs.table.refresh()
          } else {
            this.$message.error('删除失败') // + res.message
          }
        })
      },
      toggleAdvanced () {
        this.advanced = !this.advanced
      },
      onChangemodefyDate(date, dateString) {
        this.modefyDateDateString = dateString
      },
      onChangecreateDate(date, dateString) {
        this.createDateDateString = dateString
      },
      onChangemodifyDate(date, dateString) {
        this.modifyDateDateString = dateString
      },
      onChangedeleteDate(date, dateString) {
        this.deleteDateDateString = dateString
      },
      handleOk () {
        this.$refs.table.refresh()
      },
      onSelectChange (selectedRowKeys, selectedRows) {
        this.selectedRowKeys = selectedRowKeys
        this.selectedRows = selectedRows
      }
    }
  }
</script>
<style lang="less">
  .table-operator {
    margin-bottom: 18px;
  }
  button {
    margin-right: 8px;
  }
</style>
